const errorHandler = () =>
  async function (ctx, next) {
    return next().catch((err) => {
      if (err.status === 401) {
        ctx.body = {
          status: 401,
          message: `鉴权失败:${err}`,
        };
      } else {
        throw err;
      }
    });
  };

module.exports = errorHandler;
